package poker.plans.player;

import java.util.List;
import jadex.adapter.fipa.*;
import jadex.runtime.*;

public class AddPlayersPlan extends Plan {

	
	public void body() {
		//Add the players to our beliefbase
		System.out.println("PLAYER "+getAgentName()+": Adding players...");
		IMessageEvent msg = (IMessageEvent) getInitialEvent();
		AgentIdentifier[] content = (AgentIdentifier[]) msg.getContent();
		List<AgentIdentifier> players = (List) getBeliefbase().getBelief("players").getFact();
		for (AgentIdentifier aux : content) {
			//We don't add ourselves to the players list
			if (aux.getName() != getAgentName()) players.add(aux);
		}
		getBeliefbase().getBelief("players").setFact(players);
	}

}
